﻿@{
    ViewBag.Title = "ForgetPassWord";
    Layout = "~/Views/Shared/_LoginLayout.cshtml";
}
  <div class="col-md-12 text-left">
            <h3 class="btn btn-primary">找回密码</h3>
        </div>
<div class="text-center" style="line-height: 200px; padding-top: 100px; border: 1px solid #ccc;">
    <div class="row">
      
    </div>
    <div class="row ">
        <div class="col-md-2"></div>
        <div class="col-md-10">
            <form class="form-horizontal">
                <div class="form-group" style="display: inline;">
                    <input type="email" name="email" class="form-control" id="exampleInputEmail" placeholder="请输入邮箱地址" style="display: inline-block; float: left; font-weight:bold;font-size:14px;">
                    <button type="button" id="btnSend" class="btn btn-default" style="float: left;">发送邮件</button><div id="msg" style="line-height:50px;margin-left:0px;margin-top:-150px; position:relative;"></div>
                </div>
                <div class="form-group">
                    <div class="col-md-10">
                    </div>
                </div>
            </form>
        </div>
        <div class="col-md-4">
        </div>
    </div>
</div>
@section scripts{
    <script>
        $(function () {
            //光标离开验证邮件是否存在
            $("#exampleInputEmail").blur(function () {
                //url 
                $.ajax({
                    url: '/Admin/Account/CheckEmail',
                    type: 'post',
                    data: 'email=' + $("#exampleInputEmail").val(),
                    async: false, //默认为true 异步   
                    error: function () {
                        //alert('邮件地址不存在!');
                        $("#msg").attr("class", "").addClass("alert alert-danger").html("邮件地址不存在!");
                    },
                    success: function (data) {
                        if (data == "ok") {
                            $("#msg").attr("class", "").addClass("alert alert-success").html("该邮箱有效!");
                        }
                        else {
                            //alert('邮件地址不存在!');
                            $("#msg").attr("class", "").addClass("alert alert-danger");
                        }
                    }
                });
            });

            $("#btnSend").click(function () {
                //发送邮件
                $.ajax({
                    url: '/Admin/Account/SendMail',
                    type: 'post',
                    data: 'email=' + $("#exampleInputEmail").val(),
                    async: false, //默认为true 异步   
                    error: function () {
                       // alert('邮件发送失败!');
                        $("#msg").attr("class", "").addClass("alert alert-danger").html("邮件发送失败!");
                    },
                    success: function (data) {
                        $("#msg").attr("class", "").addClass("alert alert-success").html("邮件已经发送!");
                        //alert('邮件已经发送!');
                    }
                });
            });
        });
    </script>
}
